from os import path
from PIL import Image
import numpy as np
import os

from wordcloud import WordCloud

d = path.dirname(__file__) if "__file__" in locals() else os.getcwd()

alice_mask = np.array(Image.open(path.join(d, "alice_mask.png")))

wc = WordCloud(
    background_color="white",  # 背景色
    mask=alice_mask,  # 背景图
    font_path='./simsun.ttc',  # 字体
    contour_width=1,  # 边框
    contour_color='steelblue',  # 边框颜色
    collocations=False)  # 是否展示重复词

wc.generate(open(path.join(d, 'words.txt')).read())
wc.to_file(path.join(d, "alice.png"))
